package com.cheguo.zeus.web.controller;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.plugins.Page;
import com.cheguo.foundation.core.common.Result;
import com.cheguo.zeus.join.facade.JoinCarDealerService;
import com.cheguo.zeus.join.request.JoinQueryDealerInfoDto;
import com.cheguo.zeus.join.response.JoinCarDealerContractViewResponse;
import com.google.common.collect.Maps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 模块名
 *
 * @author zdf
 * @version 1.0 2018/3/16
 * @since 1.0
 */
@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private JoinCarDealerService joinCarDealerContractViewService;

    @GetMapping("/test")
    public Result test() {
        Result<Map<String, String>> ret = new Result<>();

        Map<String, String> map = Maps.newHashMap();

        map.put("name", "zdf");
        ret.setData(map);
        ret.setSuccess(true);

        return ret;
    }

    @GetMapping(value = "/user")
    @ResponseBody
    public String getUserById(JoinQueryDealerInfoDto joinQueryDealerInfoDto) {

        System.out.println("获取到的信息为" + JSON.toJSONString(joinQueryDealerInfoDto));

        Page<JoinCarDealerContractViewResponse> result = joinCarDealerContractViewService.getDealerAndContractInfoByPage(joinQueryDealerInfoDto,0,3);

        System.out.println("获取到的结果" + JSON.toJSONString(result));


//        System.out.println("获取到的结果" + JSON.toJSONString(result));
//
        return JSON.toJSONString(result);



    }


}
